/*
 * event.h
 *
 *  Created on: Aug 17, 2010
 *      Author: sdaniele
 */

#ifndef EVENT_H_
#define EVENT_H_

#include <boost/utility.hpp>
#include <boost/unordered_set.hpp>
#include "boost/concept/assert.hpp"
#include "boost/concept_check.hpp"

namespace pilot {



	class process;

	class event : private boost::noncopyable {
		public:
			event(){};

			void subscribe(process* p){
				m_subscribers.insert(p);
			}
			void signal(){
				m_is_signaled = true;
			}

		public: /*internal*/
			bool test_and_reset(){
				bool res = m_is_signaled;
				m_is_signaled = false;
				return res;
			}

			typedef boost::unordered_set<process*> container_type;

			container_type& get_subscribers(){
				BOOST_CONCEPT_ASSERT((boost::Container< boost::unordered_set<process*> >));
				return m_subscribers;
			}

		private:
			bool m_is_signaled;
			boost::unordered_set<process*> m_subscribers;

	};


}

#endif /* EVENT_H_ */
